
const tokens = {
  admin: {
    token: 'admin-token'
  },
  editor: {
    token: 'editor-token'
  }
}

const users = {
  'admin-token': {
    roles: ['admin'],
    introduction: 'I am a super administrator',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Super Admin'
  },
  'editor-token': {
    roles: ['editor'],
    introduction: 'I am an editor',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Normal Editor'
  }
}

module.exports = [
  // user login
  {
    url: '/tenant/auth/tenantLogin',
    type: 'post',
    response: config => {
      // const { username } = config.body
      // const token = tokens[username]

      // // mock error
      // if (!token) {
      //   return {
      //     code: 60204,
      //     message: 'Account and password are incorrect.'
      //   }
      // }

      return {
        code: 10000,
        data: {
          sign: 'ffffffff'
        }
      }
    }
  },
  // 二次登录校验
  {
    url: '/tenant/auth/tenantCheckAgain',
    type: 'post',
    response: config => {
      return {
        code: 10000,
        data: {
          token: 'gkfsdfdfsdf',
          tenantRoleResList: [],
          username: 'ltt',
          phone: '17600671772',
          email: ''
        }
      }
    }
  },
  // 获取商家信息
  {
    url: '/tenant',
    type: 'get',
    response: config => {
      return {
        code: 10000,
        data: {
          status: 'PASS',
          type: 'ORGAN',
          name: 'ltt',
          saleCard: 'true'
        }
      }
    }
  },

  // 店铺创建
  {
    url: '/shop/create',
    type: 'post',
    response: config => {
      return {
        code: 10000,
        data: {
          message: 'success'
        }
      }
    }
  },
  // 店铺列表
  {
    url: '/shop/list',
    type: 'post',
    response: config => {
      return {
        code: 10000,
        data: {
          list: [
            {
              id: 1,
              name: '第一家店',
              createTime: '2021-4-19',
              shopNum: 5,
              status: 'open'
            },
            {
              id: 2,
              name: '第二家店',
              createTime: '2021-4-19',
              shopNum: 5,
              status: 'open'
            },
            {
              id: 3,
              name: '第三家店',
              createTime: '2021-4-19',
              shopNum: 5,
              status: 'open'
            },
            {
              id: 4,
              name: '第四家店',
              createTime: '2021-4-19',
              shopNum: 5,
              status: 'open'
            },
            {
              id: 5,
              name: '第五家店',
              createTime: '2021-4-19',
              shopNum: 5,
              status: 'open'
            }
          ],
          listQuery: {
            total: 5,
            limit: 3,
            page: 0
          }
        }
      }
    }
  },

  // get user info
  {
    url: '/vue-element-admin/user/info\.*',
    type: 'get',
    response: config => {
      const { token } = config.query
      const info = users[token]

      // mock error
      if (!info) {
        return {
          code: 50008,
          message: 'Login failed, unable to get user details.'
        }
      }

      return {
        code: 10000,
        data: info
      }
    }
  },

  // user logout
  {
    url: '/vue-element-admin/user/logout',
    type: 'post',
    response: _ => {
      return {
        code: 10000,
        data: 'success'
      }
    }
  }
]
